"w"   #write ，清空写，生成一个新的文件，写入内容，覆盖原文件
"w+"  #write and read ，先清空文件，然后写入内容，最后才能读取写入的内容
"wb"  #write binary #，b表示二进制模式读写
"r"   #read ，只读
"rb"  #read binary ，b表示二进制模式读写
"r+"  #read and write ，不清空原文件内容，可以同时读和写,从文件的开头写入
"a"   #append ，追加写，写在原文件的后面，从文件的结尾写入
"ab"  #append binary ，b表示二进制模式读写
"a+"  #append and read ，追加写，写在原文件的后面，从文件的结尾写入

# 简单的写入文档操作
def writetxt(msg):
    try:
        with open('links1.txt', 'a+', encoding='utf-8') as f:
            f.write(msg + '\n')
    except:
        pass


#简单的读txt




#写进文档，msg是写的内容，type是分类类型
def writetxt(msg, type):
    # print(request.META)
    if type == 1:
        try:
            with open('links1.txt', 'a+', encoding='utf-8') as f:
                f.write(msg + '\n')
        except:
            pass
    elif type == 2:
        try:
            with open('links1.txt', 'a+', encoding='utf-8') as f:
                f.write(msg + '\n')
        except:
            pass
    elif type == 3:
        try:
            with open('丢弃的词汇.txt', 'a+', encoding='utf-8') as f:
                f.write(msg + '\n')
        except:
            pass